new Vue({
    el: "#mainContent",
    data: {
        videoList: [],
        listVideoUrl: "/index/get_new_video.ajax",
        deleteVideoUrl: "/video/delete_video.ajax"
    },
    mounted: function () {
        this.initPage();
    },
    methods: {
        initPage: function () {
            this.$http.get(this.listVideoUrl)
                .then((response) => {
                    this.$set(this, "videoList", response.data.data);
                })
                .catch(function (response) {
                    console.log(response)
                });
        },
        deleteVideo: function (event, video) {
            this.$http.post(this.deleteVideoUrl, {videoId: video.videoId}, {emulateJSON: true})
                .then((response) => {
                    if (Number(response.data.code) == 0) {
                        alert("删除成功!");
                        location.reload();
                    } else {
                        alert("删除失败");
                    }
                })
                .catch(function (response) {
                    console.log(response)
                });
        }
    }
});